package graphics;

import java.awt.Graphics;
import java.util.StringTokenizer;


public class Triangolo implements Forma{

	private static final int POINTS=3;
	private int x[]=new int[POINTS];
	private int y[]=new int[POINTS];
	
	public void draw(Graphics graphics) {
		graphics.drawPolygon(x, y, POINTS);
	}
	
	public void readFromString(String s) {
		
		StringTokenizer tok=new StringTokenizer(s," :");
		tok.nextToken();//Rettangolo
		for(int i=0;i<POINTS;i++){
			tok.nextToken();//stringa xi
			x[i]=new Integer(tok.nextToken());
			tok.nextToken();//stringa yi
			y[i]=new Integer(tok.nextToken());
		}
	}
	
	public String writeAsString() {
		String s="Triangolo";
		for (int i = 0; i < POINTS; i++) {
			s+=" x"+i+":"+x[i]+" y"+i+":"+y[i];
		}
		return s;
	}
	
	public void setX1(int x1){
		x[0]=x1;
	}
	public void setX2(int x2){
		x[1]=x2;
	}
	public void setX3(int x3){
		x[2]=x3;
	}

	public void setY1(int y1){
		y[0]=y1;
	}
	public void setY2(int y2){
		y[1]=y2;
	}
	public void setY3(int y3){
		y[2]=y3;
	}
	
	
	public int getX1(){
		return x[0];
	}
	public int getX2(){
		return x[1];
	}
	public int getX3(){
		return x[2];
	}

	public int getY1(){
		return y[0];
	}
	public int getY2(){
		return y[1];
	}
	public int getY3(){
		return y[2];
	}
}
